﻿/***************************************************************************
 *    
 *      Copyright (c) 2009,2010 KaiTrade LLC (registered in Delaware)
 *                     All Rights Reserved Worldwide
 *
 * STRICTLY PROPRIETARY and CONFIDENTIAL
 *
 * WARNING:  This file is the confidential property of KaiTrade LLC For
 * use only by those with the express written permission and license from
 * KaiTrade LLC.  Unauthorized reproduction, distribution, use or disclosure 
 * of this file or any program (or document) is prohibited. 
 * 
 ***************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace K2AlgoSet
{
    class ExpressionFactory : KaiTrade.Interfaces.K2InstanceFactory
    {
         /// <summary>
        /// Singleton OrderManager
        /// </summary>
        private static volatile ExpressionFactory s_instance;

        /// <summary>
        /// used to lock the class during instantiation
        /// </summary>
        private static object s_Token = new object();

        private List<string> m_Names;

        /// <summary>
        /// Logger
        /// </summary>
        public log4net.ILog m_Log = log4net.LogManager.GetLogger("Kaitrade");

       

        public static ExpressionFactory Instance()
        {
            // Uses "Lazy initialization" and double-checked locking
            if (s_instance == null)
            {
                lock (s_Token)
                {
                    if (s_instance == null)
                    {
                        s_instance = new ExpressionFactory();
                    }
                }
            }
            return s_instance;
        }

        protected ExpressionFactory()
        {
            m_Names = new List<string>();
            m_Names.Add("KATR");
            m_Names.Add("KMVA");
            m_Names.Add("K2MVA");

        }


        public object CreateInstance(string name)
        {
            object myObject = null;
            switch (name)
            {
                case "KATR":
                    myObject = new ATR();
                    break;
                case "KMVA":
                    myObject = new SimpleMovingAverage();
                    break;
                case "K2MVA":
                    myObject = new SimpleMovingAverage();
                    break;
                default:
                    break;
            }
            return myObject;
        }

        public List<string> Names
        {
            get { return m_Names; }
        }
    }
}
